<template>
  <div class="full-height">
    <div class="homepage">
      <view-box>
        <div class="index-bg">
          <img src="../../static/images/party-h5-index-bg.png" />
        </div>
        <div class="index-text">
          <img src="../../static/images/party-h5-index-text.png">
        </div>
        <div class="start-btn" @click="toExam">
          <img src="../../static/images/party-h5-btn.png">
        </div>
      </view-box>
    </div>
  </div>
</template>

<script>
import { getSubscribe } from '@/api/exam';

/**
 * 判断是否是微信
 */
const isWechat = () => {
  const checkResult = (/micromessenger/i).test(window.navigator.userAgent.toLowerCase())
  return checkResult;
};

export default {
  data() {
    return {
      subscribe: {
        type: Number
      }
    }
  },
  methods: {
    toExam() {
      if (isWechat()) {
        if (this.subscribe == 1) {
          this.$router.push({
            path: '/exam'
          })
        } else {
          this.$router.push({
            path: '/QRcode'
          })
        }
      } else {
        alert('请进入微信答题');
      }
    }
  },
  created() {
    getSubscribe().then(res => {
      this.subscribe = res.data.subscribe;
    })
  }
}
</script>

<style>

</style>
